﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CardInChina.Web.Mvc
{
    public class HttpAjaxPostAttribute : ActionMethodSelectorAttribute
    {
        private static readonly AcceptVerbsAttribute _innerAttribute = new AcceptVerbsAttribute(HttpVerbs.Post);

        public override bool IsValidForRequest(ControllerContext controllerContext, System.Reflection.MethodInfo methodInfo)
        {
            if (_innerAttribute.IsValidForRequest(controllerContext, methodInfo) 
                && controllerContext.HttpContext.Request.IsAjaxRequest())
            {
                return true;
            }
            else
                return false;
        }
    }
}